<template>
	<div>
		<el-card>
			<el-row
				:gutter="20"
				style="
					padding-bottom: 16px;
					box-sizing: border-box;
					display: flex;
					justify-content: center;
				"
			>
				<!-- <el-col :span="7">
					<el-input
						placeholder="输入用户id以查询考试记录"
						v-model="idForSearch"
						style="height: 34px;"
					></el-input>
				</el-col> -->
				<el-button
					type="primary"
					:icon="Search"
					@click="searchById()"
				>
					查询考试记录
				</el-button>
			</el-row>

			<el-table :data="tableData" stripe style="width: 100%">
				<el-table-column
					v-for="(item, index) in options"
					:key="index"
					:prop="item.prop"
					:label="item.label"
					:width="item.width"
				></el-table-column>
			</el-table>

			<el-pagination
				v-model:current-page="queryForm.pageNum"
				v-model:page-size="queryForm.pageSize"
				:page-sizes="[2, 5, 10, 15]"
				layout="sizes, prev, pager, next"
				:total="1000"
			/>
		</el-card>
		<addQstionDialogue v-model="addDialogVisible"></addQstionDialogue>
		<updateQstionDialogue
			v-model="updateDialogVisible"
		></updateQstionDialogue>
	</div>
</template>

<script setup lang="ts">
import addQstionDialogue from '@/components/dialogue/addQstionDialogue.vue'
import updateQstionDialogue from '@/components/dialogue/updateQstionDialogue.vue'
import { Search } from '@element-plus/icons-vue'
import { options } from './options'
import { ref, Ref } from 'vue'
import type { ExamHistory } from '@/api/test/examHistory'
import { getLeveExamByUserId } from '@/api/test/examHistory'
import useUserStore from '@/store/modules/user'

const addDialogVisible = ref(false)
const updateDialogVisible = ref(false)
const queryForm = ref({
	pageNum: 1,
	pageSize: 50
})
const tableData: Ref<ExamHistory[]> = ref([])
const useStore = useUserStore()
//查找用户
const searchById = async () => {
	const userId = parseInt(useStore.userId,10)
		const res = await getLeveExamByUserId(userId)
   
			// tableData.value = []
			tableData.value=res
	
}
</script>

<style scoped>
.header {
	margin-bottom: 20px;
	box-sizing: border-box;
}
</style>
